package com.eshipenet.shipnet.commplanrpc.ignite;


import com.eshipenet.shipnet.commplan.CommCard;
import com.eshipenet.shipnet.commplan.CommPlan;
import com.eshipenet.shipnet.commplanrpc.service.CommCardServiceImp;
import com.eshipenet.shipnet.commplanrpc.service.CommPlanIdGenerator;
import com.eshipenet.shipnet.commplanrpc.service.CommPlanIdGeneratorImpl;
import com.eshipenet.shipnet.commplanrpc.service.CommPlanServiceImp;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.Ignition;
import org.apache.ignite.configuration.CacheConfiguration;

public class CommPlanIgnite {

    public  static  Ignite ignite;

    public synchronized static Ignite ignite() {

        if (ignite == null){
            ignite = Ignition.start("CommPlan-server.xml");
            


            CacheConfiguration<String, CommPlan> cacheCfg = new CacheConfiguration<String, CommPlan>("CommPlan");
            cacheCfg.setIndexedTypes(String.class, CommPlan.class);
            IgniteCache<String, CommPlan> commPlanCache = ignite.getOrCreateCache(cacheCfg);
            ignite.services().deployMultiple("CommPlanService", new CommPlanServiceImp(commPlanCache), 1, 1);


            CacheConfiguration<String, CommCard> commCardcacheCfg = new CacheConfiguration<String, CommCard>("CommCard");
            commCardcacheCfg.setIndexedTypes(String.class, CommCard.class);
            IgniteCache<String, CommCard> commCardCache = ignite.getOrCreateCache(commCardcacheCfg);
            ignite.services().deployMultiple("CommCardService", new CommCardServiceImp(commCardCache), 1, 1);

              }

        return ignite;
    }


}
